﻿using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SCM.API.Write.Application.Command.Purchase;
using SCM.Domain;
using SCM.ErrorCode;

namespace SCM.API.Write.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    
    public class PurchaseController : ControllerBase
    {
        IMediator mediator;

        public PurchaseController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        [HttpPost]
        public async Task<APIResult<int>> AddPurchase(AddPurchaseCommand request)
        {
            return await mediator.Send(request);
        }
        [HttpPut]
        public Task<APIResult<int>> DelPurchase(DelPurchaseCommand request)
        {
            return mediator.Send(request);
        }
        [HttpPut]
        public Task<APIResult<int>> UpdatePurchase(UpdatePurchaseCommand request)
        {
            return mediator.Send(request);
        }
        [HttpPut]
        public Task<APIResult<int>> AddWareHouse(AddWareHouseCommand request)
        {
            return mediator.Send(request);
            }
        [HttpPut]
        public Task<APIResult<int>> UpdateRecord(UpdateRecordedCommand request)
        {
            return mediator.Send(request);
        }
        [HttpGet]
        public Task<APIResult<PurchaseManagementModel>> FanPurchase([FromQuery]UpdPurchaseCommand request)
        {
            return mediator.Send(request);
        }
    }
}
